package com.axjy.redis01.service;

import com.axjy.redis01.mapper.AreaMapper;
import com.axjy.redis01.pojo.TpArea;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service("areaService")
public class AreaServiceImpl implements AreaService{

    @Resource
    private AreaMapper areaMapper;

    @Cacheable(value="tpp:area")
    @Override
    public List<TpArea> searchArea(int level) {
        System.out.println("执行service方法");
        LambdaQueryWrapper<TpArea> wrapper= Wrappers.lambdaQuery();
        wrapper.eq(TpArea::getLevel,level);
        return areaMapper.selectList(wrapper);
    }

    @Cacheable(value="tpp:createuuid")
    public String createUUID(){
        return "我是"+ UUID.randomUUID().toString();
    }
}
